package gui;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class RadioButtonTest
{
	public static void main (String [] args) {
		Display display = new Display ();
		final Shell shell = new Shell (display);
		shell.setLayout (new RowLayout (SWT.VERTICAL));
		for (int i=0; i<8; i++) {
			final Button button = new Button (shell, SWT.RADIO);
			button.setText ("B" + i);
			if (i == 0) button.setSelection (true);
			button.addSelectionListener(new SelectionListener()
			{
				
				@Override
				public void widgetSelected(SelectionEvent arg0)
				{
					System.out.println(button.getText());					
				}
				
				@Override
				public void widgetDefaultSelected(SelectionEvent arg0)
				{
					System.out.println(button.getText());					
				}
			});
		}
		
		
		
		shell.pack ();
		shell.open ();
		while (!shell.isDisposed ()) {
			if (!display.readAndDispatch ()) display.sleep ();
		}
		display.dispose ();
	}

}
